package algorithm;

/**
 * Created by kevin on 15-1-4.
 */
public class LectureCourse {
    private Student[] students;
    private int registered = 0;
    private final String name;

    public LectureCourse(int size,String name){
        this.name = name;
        students = new Student[size];
    }

    public void register(Student student){
        if(registered<students.length){
            students[registered] = student;
            registered++;
        }
    }

    public void print(){
        System.out.println("Course " + name + ": ");
        for(int i=0;i<registered;i++){
            students[i].print();
        }
    }

    public static LectureCourse createCourse(String[] names){
        LectureCourse c = new LectureCourse(names.length,"MA407");
        for(int i=0;i<names.length;i++){
            Student student = new Student(names[i],1000 + i);
            c.register(student);
        }
        return c;
    }

    public static void main(String args[]){
        if(args.length > 0){
            LectureCourse course = createCourse(args);
            course.print();
        }
    }
}
